<?php

Raise::load('control.RaiseTimeAgo');
Raise::load('core.RaiseJavascript');

class IndexPage extends AppPage {

    function __construct(){
        parent::__construct('default');
    }

    function prepareTimeAgo(){
        $file = new RaiseFile(RaisePath::combine(RaisePath::phpRaisePath(), 'raise.php'));
        $c = new RaiseTimeAgo($file->getLastModified(), 3, true, new RaiseTimeSpan(120));
        $c->clientId('timeAgo');

        $this->fields()->add('timeAgo', $c);
    }

    function build(){
        $this->title('phpRaise PHP Framework');

        $this->fields()->add('default', RaiseJavascript::helper($this->application()->request()->getUrl()) . '$contentAjax$<br /><br />$timeAgo$ since Raise.php was modified.');
        $this->fields()->add('contentAjax', new AjaxTimeDisplay('updater'));

        $this->prepareTimeAgo();
    }

}